extends Ally

@export var speed = 1000

@onready var anim: AnimatedSprite2D = $Anim

var direction = Vector2.ZERO
var target = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	# target = get_tree().get_first_node_in_group("player")
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	# direction = target.global_position - self.global_position
	direction = Vector2(1280,720) - self.global_position
	anim.flip_h = direction.x<0
	if direction.length()>0:
		direction = direction.normalized()
		anim.play("run")
	else :
		anim.play("idle")
	velocity = delta*speed*direction
	move_and_slide()
	pass
